﻿CREATE PROCEDURE [Event].[GetEvent]
	@EventID INT
WITH EXECUTE AS OWNER
AS
SET NOCOUNT ON;

SELECT ee.EventID,
       ee.OwnerID,
       aa.DisplayName AS OwnerDisplayName,
       ee.AttendeeListVisibilityID,
       ealv.AttendeeListVisibilityDescription,
       ee.Title,
       ee.Description,
       ee.Cost,
       ee.PaymentAccepted,
       ee.PaymentRefundable,
       ee.InvitationOnly,
       ee.Searchable,
       ee.SearchEngineURL,
       el.LocationID,
       el.Title,
       el.Address1,
       el.Address2,
       el.City,
       el.State,
       el.PostalCode,
       el.Directions
  FROM Event.Events AS ee
       INNER JOIN Event.AttendeeListVisibility AS ealv
          ON ee.AttendeeListVisibilityID = ealv.AttendeeListVisibilityID
       INNER JOIN Auth.Accounts AS aa
          ON ee.OwnerID = aa.AccountID
        LEFT OUTER JOIN Event.Locations AS el
          ON ee.LocationID = el.LocationID
 WHERE EventID = @EventID;

SELECT es.ScheduleID,
       es.Description,
       es.StartTime,
       es.EndTime
  FROM Event.Schedule AS es
 WHERE es.EventID = @EventID;
